<?php
error_reporting(0);
include("home.class.php");
include("function.php");
include("mail/sendmail.php");
//判断登陆

judgeLogin();

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--<meta http-equiv="X-UA-Compatible" content="IE=7" /><!--如果是IE8时强制以IE7显示-->
<meta name="keywords" content="食品笔记,食品,食品安全,饮食,饮食安全,生活"><!--SEO关键字-->
<meta name="description" content="食品笔记，你的饮食安全卫士"><!--SEO描述-->
<link rel="shortcut icon" type="image/ico" href="images/favicon.ico"><!--选项卡图标-->
<title>食品笔记 - 让生活更健康</title>
<link rel="stylesheet" href="css/base.css">
<link rel="stylesheet" href="css/common.css">
<link rel="stylesheet" href="css/style.css">

<!--[if ie]>
<link rel="stylesheet" href="css/ie.css">
<script type="text/javascript" src="js/DD_belatedPNG.js" ></script>
<script type="text/javascript">
DD_belatedPNG.fix('.png');/*在需要png透明的元素里面加上.png样式即可（class="png"）*/
</script>
<![endif]-->
</head>
<body>
	<div class="header w pr"><!-- header -->
		<div class="index-header w960 bc pr">
			<a href="home.php" class="score_logo score_img dib png fl mt10"></a>
			<div class="header_right fr">
				<ul class="header_nav fl tc fb f12 h">
					<li><a href="home.php" class="header_nav_hover">首 页</a></li>
					<li><a href="report.php">饮食报告</a></li>
					<li><a href="newsmap.php">食品新闻</a></li>
					<li><a href="food.php">选食专栏</a></li>
					<li><a href="timeline.php">时光轴</a></li>
					<li><a href="share.php">分享</a></li>
				</ul>
				<a href="massage.php" class="header_myMessage tc fr ml5" title="私信"><?php echo showCountMassage($_SESSION['login_mail']);?></a><!-- 私信 -->
				
				<div class="header_myInfo fr f14 h pr">
					<a href="#" class="header_setup"><img src="<?php if(!empty($_SESSION['qq_nickname'])): echo $_SESSION['qq_photoUrl']; else: echo showUserPhoto();endif;?>" alt="" class="fl" /></a><!-- user_avatar -->
					<a href="#" class="fl header_setup"><?php echo showUserName();?></a><!-- user_nickname -->
					<div class="header_myInfoArrow score_img fl"></div>
					<ul class="header_hideInfo none pa tc w"><!-- hide_info -->
						<li><a href="#" class="header_setup">个人设置</a></li>
						<li><a href="modifymail.php">修改邮箱</a></li>
						<li><a href="password.php">修改密码</a></li>
						<li><a href="login_out.php">退出登录</a></li>
					</ul>
				</div>
				
			</div>
			<div class="score_img content_top pa"></div>
		</div>
	</div><!-- end_header -->

	<div class="score_main pr oh h"><!-- score_main -->
		<div class="main w960 bc h">
			<div class="score_sider fl mt20">
				<div class="main_avatar">
					<img src="<?php if(!empty($_SESSION['qq_nickname'])): echo $_SESSION['qq_photoUrl']; else: echo showUserPhoto();endif;?>" alt="" class="score_avater mb20" /><!-- main_avatar -->
					<p><a href="#" class="score_nickname f18 fb header_setup"><?php echo showUserName();?></a> | <a href="massage.php" class="sider_message">私信(<?php echo showCountMassage($_SESSION['login_mail']);?>)</a></p><!-- main_nickname -->
				</div>
			</div>
			<div class="content fr pr">
				<div class="score_contentBg bc pr inputWrap oh">
					<form action="" class="f18 score_form score_inputWay pr">
					<input type="hidden" class="hiddenUserId" value="<?php echo $id = getUserId($_SESSION['login_mail']);?>" />
						<fieldset class="ml20 appendEatSub">
							<div class="mr30 js_eatWhat">
								<p class="pt30"><label for="">你今天吃了什么？</label><a href="" class="fr f14 change_Input">换一种输入法 →</a></p>
								<p><input type="text" class="score_eatWhat mt10 score_text pl5 pr5" autocomplete="off" id="eatWhat" value="" /></p>
							</div>
							<div class="mt30 slideBar">
								<p><label for="" class="f18 cblue">吃了多少？</label></p>
								<p class="mt10 oh">
									<div class="fl pr ml10">
										<div class="score_slideBar"></div>
										<div class="pa score_slideBlock" id="drag"></div>
									</div>
									<input type="hidden" class="score_eatHowmany mt10 score_text pl5 pr5" id="eatHowMany" /><span class="score_unit f22 mr30 fr"><span class="showHowMany">0</span>克</span>
								</p>
							</div>
							<p class="subEatFood"><input type="submit" value="确认提交" class="mt20 mb30 score_img png score_eatSub f18 jquery_score_button cf" id="jquery_score_button" /></p>
						</fieldset>
					</form>
					<div class="food_selector pb30 pr score_inputWay pr none"><!-- 城市选择器 -->
						<h4 class="f22 mt20 ml20">请选择一种食物</h4>
						<a href="#" class="city_slider pa change_Input">← 使用原来的输入法</a>
						<hr class="news_hr mb10" />
						<div class="city_province ml20">
							<h5 class="f20"><span class="score_img png city_step1 mr5 fl"></span>食品分类</h5>
							<p class="jq_category f16 mt10 pl30"></p>
						</div>
						<div class="city_cities mt20 ml20">
							<h5 class="f20"><span class="score_img png city_step2 mr5 fl"></span>食品类型</h5>
							<p class="jq_detailFood f16 mt10 pl30"></p>
						</div>
						<div class="js_foodName mt20 ml20 none">
							<h5 class="f20"><span class="score_img png city_step3 mr5 fl"></span>食品名</h5>
							<p class="jq_lastFood f16 mt10 pl30"></p>
						</div>
						<hr class="news_hr mb10" />
						<div class="ml20 mt30 appendEatSub">
							<div class="f18 cblue js_eatWhat">你选择了：<span class="a3 js_foodNameBox"></span></div>
						</div>
					</div>
				</div>
				
				
				<ul class="pa ajax_foodName none pr"></ul>
				<div class="score_contentBg mt20 bc score_foodScore pt10 pr">
					<table class="mt15 ml20 score_foodTable tc">
						<tr class="cf f18 zy_parent">
							<th class="score_img score_thBgPos tc">时间</th>
							<th class="score_img score_thBgPos tc">吃了啥</th>
							<th class="score_img score_thBgPos tc">吃了多少(kg)</th>
							<th class="score_img score_thBgPos2 tc">修改</th>
						</tr>
						
						<?php
							$login_mail = $_SESSION['login_mail'];
							$data = getUserNormalFoodData($login_mail);
							//print_r($data);
							if(empty($data[0]['eatwhat'])):
								echo '<tr class="report_noData mt50 tc f20"><td colspan=4 style="width:auto"> Sorry ! 我还不知道你今天吃了什么呢 O(∩_∩)O~~~</td></tr>';
							else:
							foreach($data as $key=>$value):
								$create_time = substr($value['create_time'],10,6);
								echo "
								<tr class=\"score_foodTbody\">
									<td>$create_time</td>
									<td class='zy_eatWhat'>$value[eatwhat]</td>
									<td>$value[eathowmany]</td>
									<td>
										<a href=\"\" class=\"score_delete\">删除该项目</a>
										<input type=\"hidden\" class=\"hidden_data_id\" value=\"$value[data_id]\">
									</td>
								</tr>
								";
							endforeach;
							endif;
						?>
					</table>
					<input type="submit" value="饮食打分" class="mt20 mb30 score_img png score_eatSub f18 jquery_score_button cf ml20" id="score_sub"/>
				</div>
				<?php
					header("Content-type:text/html; charset=utf8");
					$userId = getUserId($login_mail);
					$username = getUserNick($login_mail);
					$tipData = getUserHistoryScoreTip($userId,$username);
					//print_r($tipData);
				?>
				<div class="score_advice mt80 bc oh">
					<div class="score_yourScore score_img cf fl png">
					<span>
					<?php 
						if(is_array($tipData)):foreach($tipData as $score1=>$tip1):echo $score1.'\'';endforeach;
						else:echo '-';
						endif;
					?>
					</span>
					
					</div>
					<div class="fl score_adviceP mt80 pb10 ml30">
						<p class="f18 dib w"><span class="fl score_img png score_adviceQoute mr10 mt5"></span>
						<?php 
							if(is_array($tipData)):
							foreach($tipData as $score=>$tip):echo $tip;endforeach;
							else:echo '您今日的饮食健康结果！';
							endif;
						?></p>
						<div class="mt20">
							<?php if(is_array($tipData)):?>
							<div class="home_share fl png"></div>
							<?php endif;?>
							<a href="report.php" class="tr fr dib score_lookDetails">查看详情→</a>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div><!-- end_score_main -->

	<div class="footer w"><!-- footer -->
		<div class="w960 bc pr tc">
			<div class="content_footer score_img pa"></div>
			<p class="pt30"><a href="#" class="iphone-app f12 a3 mr10 dib oh"><span class="iphone-app-img dib png fl ml5"></span>iphone应用</a>
			<a href="foodnote.apk" class="android-app f12 a3 dib oh"><span class="android-app-img dib png fl ml5"></span>android应用</a></p>
			<p class="f12 tc mt10"><a href="#" class="a3">关于我们</a><span class="ml10 mr10">|</span><a href="#" class="a3">使用条款</a><span class="ml10 mr10">|</span><a href="#" class="a3">常见问题</a></p>
			<p class="a3 f12 c91 mt10">Copyright &copy; 2011-2012 Foodnote&nbsp;&nbsp;&nbsp;&nbsp; 湘ICP备09004495号-5</p>
		</div>
	</div><!-- end_footer -->
	
	<?php
		//判断是否新用户登录
		$login_mail = $_SESSION['login_mail'];
		$login_status = judgeNewUser($login_mail);
		
		//获取用户数据
		$userData = getUserBasicInfo($_SESSION['login_mail']);
		
		if($login_status == 0)
		{
			echo "<div class='novice_login png pa w'>";
		}else
		{
			echo "<div class='novice_login png pa w none'>";
		}
	?>
		<div class="personal_info bc oh pb50 pr">
			<div class="personal_close score_img pa"></div>
			<h2 class="personal_title ml50 mt20 mb20">个人信息录入</h2>
			
			<form action="home.php" method="post" class="ml50">
				<fieldset class="fl">
					<p class="mt10"><label for="" class="personal_label f22">性别</label></p>
					<p class="mt10"><small class="personal_small f14">请选择：男/女</small></p>
					<p class="mt10">
						<select class="score_text score_select pl5 pr5 " name="sex">
					<?php  
						if($userData['user_sex']=="男"):
						
							echo "<option value='男' selected >男</option>";
							echo "<option value='女'>女</option>";
						
						elseif($userData['user_sex']=="女"):
						
							echo "<option value='男'>男</option>";
							echo "<option value='女' selected>女</option>";
						
						else:
						
							echo "<option value='' selected>--</option>";
							echo "<option value='男'>男</option>";
							echo "<option value='女'>女</option>";
						endif;
					?>
								
						</select>
					</p>
					<p class="mt10"><label for="" class="personal_label f22">年龄</label></p>
					<p class="mt10"><small class="personal_small f14">不同的年龄对饮食的需求不同，例如:23</small></p>
					<p class="mt10"><input type="text" class="score_text zy_ageVal pl5 pr5" name="age" value="<?php echo $userData['user_age'];?>"/></p>
					<p class="mt10"><label for="" class="personal_label f22">现居地</label></p>
					<p class="mt10"><small class="personal_small f14">请输入您现居地的省份名，例如:湖南</small></p>

					<p class="mt10">
						<select class="score_text score_select pl5 pr5 " name="city">
							<option value='<?php echo $userData['user_city'];?>' selected><?php echo $userData['user_city'];?></option>
							<option value='安徽'>安徽</option>
							<option value='福建'>福建</option>
							<option value='港澳台藏'>港澳台藏</option>
							<option value='甘肃'>甘肃</option>
							<option value='广东'>广东</option>
							<option value='广西'>广西</option>
							<option value='贵州'>贵州</option>
							<option value='海南'>海南</option>
							<option value='河北'>河北</option>
							<option value='黑龙江'>黑龙江</option>
							<option value='河南'>河南</option>
							<option value='湖北'>湖北</option>
							<option value='湖南'>湖南</option>
							<option value='江苏'>江苏</option>
							<option value='江西'>江西</option>
							<option value='吉林'>吉林</option>
							<option value='辽宁'>辽宁</option>
							<option value='内蒙古'>内蒙古</option>
							<option value='宁夏'>宁夏</option>
							<option value='青海'>青海</option>
							<option value='山东'>山东</option>
							<option value='山西'>山西</option>
							<option value='陕西'>陕西</option>
							<option value='四川'>四川</option>
							<option value='云南'>云南</option>
							<option value='新疆'>新疆</option>
							<option value='浙江'>浙江</option>
							<option value='直辖市'>直辖市</option>
						</select>
					</p>

					<p class="mt10"><label for="" class="personal_label f22">体重</label></p>
					<p class="mt10"><small class="personal_small f14">不同的体重对饮食的需求不同，单位：kg</small></p>
					<p class="mt10"><input type="text" class="score_text zy_weightVal pl5 pr5" name="weight" value="<?php echo $userData['weight'];?>"/> kg</p>
					<input type="hidden" value="<?php echo basename($_SERVER['PHP_SELF']);?>" name="fileName" />
					<input type="hidden" value="true" name="submited" />
					<input type="submit" value="确认提交" name="submit" class="personal_submit pa f18" />
				</fieldset>
			</form>
			<form method="post" action ="upload.php" enctype="multipart/form-data" target="hidden_frame" class="none">
				<fieldset>
					<input type="file" name="photo" id="photo" onchange="cli('p_submit');"/>
					<input type="submit" name="p_submit" value="保存" id="p_submit">
					<iframe name='hidden_frame' id="hidden_frame" style="border:none;" onreadystatechange="reflesh('<?php echo $_SESSION[login_mail]?>');"></iframe>
				</fieldset>
			</form>
			<form action="home.php" method="post" class="ml50">
				<fieldset>
					<a href="javascript:void(0)" onclick="cli('photo');"><img id="img" src="<?php if(!empty($_SESSION['qq_nickname'])): echo $_SESSION['qq_photoUrl']; else: echo showUserPhoto();endif;?>" class="personal_avatar pa" />
					<span class="pa click_upload">+点击上传头像</span>
					</a>
					<a href="javascript:void(0)" class="pa avatar_refresh" onclick="reflesh('<?php echo $_SESSION[login_mail]?>');">刷新</a>
				</fieldset>
			</form>
		</div>
	</div>
	
	<?php //qq_state 
	$qq_status = qq_status($login_mail); 
	if(isset($_SESSION['qq_nickname']) && $qq_status == 0):
	?>
	<div class="qq_tips_bg png pa w"><!-- QQ登陆提醒 -->
		<div class="qq_tips bc oh pb50 pr">
			<div class="qq_close score_img pa"></div>
			<h2 class="personal_title ml50 mt20 mb20">温馨提示</h2>
			<div class="qq_tipsh oh ml50 f14">
				<img src="images/tips_smile.png" alt="" class="fr png mr150" /><!-- 提示图片 -->
				<p>亲爱的</span class="a69"><?php echo $_SESSION['qq_nickname']; ?></span></p>
				<input type="hidden" class="qq_user_mail" value="<?php echo $login_mail;?>">
				<p>欢迎来到<span class="a69">食品笔记</span></p>
				<p>你的登陆账号为:<?php echo $_SESSION['login_mail'];?></p>
				<p>密码为:<?php echo $_SESSION['user_prepassword'];?></p>
				<p>为了方便下次登录，请即时<a href="password.php">修改密码</a>。</p>
			</div>
		</div>
	</div>
	<?php endif;?>
	
	<div id="scroeLoading" class="none png">
		<div class="loadingCenter bc pr">
			<div class="scoreLoading_bar bc pr"><div class="scoreLoading_cover pa"></div></div>
			<p class="loadingTips mt20 bc tc"></p>
		</div>
	</div>
	
	<div class="shareWrap tc w h none"><!-- 分享板 -->
		<div class="shareBg pa h w png"></div>
		<div class="shareBoard vm w700 dib bc tl pr">
			<div class="shareHead mt20 bc oh">
				<h3 class="a3 f24 fl">分享</h3><span class="shareLimit fr"><!--还可以输入 <strong class="">120</strong> 字--></span>
			</div>
			<form action="" class="share_form bc mt5" method="post">
				<textarea name="message" cols="30" rows="10" class="share_textarea"></textarea>
				<div class="shareFooter mt10 oh pb30">
					<span class="shareTip fl">经常登录<a href="www.foodnote.net/home.php">食品笔记</a>有益健康哦</span>
					<input type="submit" value="分享" class="shareBtn fr" />
				</div>
			</form>
		</div>
		<span class="verticalMiddle h vm dib"></span>
	</div>
	
	<!-- JavaScript -->
<script type="text/javascript" src="js/jquery-1.6.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript" src="js/slider_bar.js"></script>
	<?php if(!empty($_SESSION['qq_nickname'])){ ?>
<script type="text/javascript">  
	$(document).ready(function(){
		$('.qq_tips').show();
		
		$('.qq_close').click(function(event){
			$('.qq_tips_bg').hide();
		});
	})
</script>
	<?php } ?> 
<script type="text/javascript">  
 
 function cli(id){  
		var sub = document.getElementById(id);
   sub.click();  
//   if (/msie/i.test(navigator.userAgent)) //IE  
//   {  
//      sub.fireEvent("onclick");  
//   } else {  
//      var e = document.createEvent('MouseEvent');  
//      e.initEvent('click', false, false);  
//      sub.dispatchEvent(e);  
//   }
}

function reflesh(user){
	image_src="image.php?user_mail="+user+"&math="+Math.random(1);
	//alert(image_src);
	document.getElementById("img").src=image_src;
	
	}	

</script> 
<div class="none">
<script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fbba169f4f4508eb5cc1c5618eeb3c59d' type='text/javascript'%3E%3C/script%3E"));
</script>
</div>
</body>

</html>
